﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PageMethod.aspx.cs" Inherits="AutoComplete.PageMethod" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" src="<%= ResolveClientUrl("~/Scripts/jquery-1.5.1.min.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveClientUrl("~/Scripts/jquery-ui-1.8.10.custom.min.js") %>"></script>
    <link href="<%= Page.ResolveUrl("~/css/custom-theme/jquery-ui.css") %>" rel="stylesheet"
        type="text/css" media="screen,projector" />
<script type="text/javascript">
    var textBox = "#<%=TextBox1.ClientID %>";

    $(document).ready(function () {

        $.ajax({
            type: "POST",
            url: '<%= ResolveUrl("~/PageMethod.aspx/Stations") %>',
            dataType: "json",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                var stations = data.d;
                $(textBox).autocomplete({
                    source: stations
                });
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            }
        });
    });
       

</script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>
